package com.firexxx.study.designmodel.mediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2019/11/14 15:46
 */
public class Mediator {
    private List<IUser> userList = new ArrayList();

    public void add(IUser observer) {
        userList.add(observer);
    }

    public void remove(IUser observer) {
        userList.remove(observer);
    }

    public void relay(String name) {
        userList.stream().filter(u -> u.getName().equals(name)).forEach(u -> u.response());
    }
}